package com.crack.nga2.volley;

import com.android.volley.AuthFailureError;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.NetworkResponse;
import com.android.volley.Request;
import com.android.volley.Response;
import com.crack.nga2.utils.GlobalConst;

import java.util.HashMap;
import java.util.Map;

/**
 * 请求基类
 * Created by Administrator on 2016/1/11.
 */
public abstract class BaseRequest<T> extends Request<T> {
    public BaseRequest(int method, String url, Response.ErrorListener listener) {
        super(method, url, listener);
        setRetryPolicy(new DefaultRetryPolicy(15000, 1, 1));
    }

    @Override
    public Map<String, String> getHeaders() throws AuthFailureError {
        Map<String, String> headers = new HashMap<>();
        if (GlobalConst.isLogin) {
            headers.put("Cookie", GlobalConst.Cookie);
            return headers;
        } else {
            headers.put("Cookie", GlobalConst.NO_LOGIN_COOKIE);
            return headers;
        }
    }

}
